integrate and implement open telemetry tracing#18534
Conversation
119f1c7 to
49d6041
Compare
f070e75 to
3fd2443
Compare
|
@highker could we get a first pass on this? |
tanjialiang
left a comment
There was a problem hiding this comment.
Reviewed the first commit
presto-main/src/main/java/com/facebook/presto/tracing/OpenTelemetryTracer.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Do we need to take care of any unfinished Span?
There was a problem hiding this comment.
Can you help me understanding the closing logic of opentelemetry here? Thank you
There was a problem hiding this comment.
I am looking into this
There was a problem hiding this comment.
@tanjialiang Addressed by ending any unended spans at the time of ending trace.
presto-main/src/main/java/com/facebook/presto/tracing/OpenTelemetryTracer.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/tracing/OpenTelemetryTracerProvider.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/tracing/OpenTelemetryTracer.java
Outdated
Show resolved
Hide resolved
a2a2097 to
e932e63
Compare
presto-main/src/main/java/com/facebook/presto/server/ServerMainModule.java
Outdated
Show resolved
Hide resolved
presto-spi/src/main/java/com/facebook/presto/spi/tracing/TracerProvider.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/tracing/TracingConfig.java
Outdated
Show resolved
Hide resolved
5173a23 to
35a6292
Compare
936cf9e to
ee19b16
Compare
|
Hey @highker, I want to try to get my changes pushed through by the end of next week if possible. If there's anything in this PR that still needs further discussion or you still want revised, I'm happy to remove it from this PR and address it as a new one for the future if that works. |
highker
left a comment
There was a problem hiding this comment.
Please squash all commits into one.
I have one major comment in the end. Please check that one first.
There was a problem hiding this comment.
Let's remove these headers to presto-open-telemetry. Check my other comment
There was a problem hiding this comment.
Can we use the header instead of session property to control the flags?
There was a problem hiding this comment.
Let's refactor the code a bit so we don't have to use session property or the header explicitly. Check my other comment
There was a problem hiding this comment.
Move this to presto-open-telemetry module. Check my other comment
There was a problem hiding this comment.
nit
@Nullable
private TracerProvider tracerProvider;There was a problem hiding this comment.
directly return instead of creating openTelemetry
There was a problem hiding this comment.
[Major] this is my major comment.
Similar to many other "handle" classes in our codebase, let's create a handle interface in com.facebook.presto.spi.tracing:
public interface TracerHandle
{
}Change the signature of getNewTracer to
Tracer getNewTracer(TracerHandle handle);Create a new method of TracerProvider:
/**
* The method returns a function to take a set of HTTP headers and generate the tracer handle
*/
Function<Set<String>, TracerHandle> getHandleGenerator();In your OpenTelemetry implementation, you should have
public class OpenTelemetryTracerHandle
implements TracerHandle
{
private final String traceToken;
private final String contextPropagator;
private final String propagatedContext;
private final String baggage;
...
}In your OpenTelemetryTracerProvider, you should have
@Override
public Tracer getNewTracer(TracerHandle handle)
{
OpenTelemetryTracerHandle tracerHandle = (TracerHandle) handle;
return new OpenTelemetryTracer(tracerHandle.getXXX, ...);
}In your getHandleGenerator implementation, move all the logics you have in presto-main here so we can hide all those headers and specialized extraction methods.
d171ea9 to
1e44c8f
Compare
|
@highker Trace handle implementation done |
highker
left a comment
There was a problem hiding this comment.
awesome change! All nits. Otherwise, good to go
There was a problem hiding this comment.
I know it's a bit anti pattern; but in order to keep the logic so we don't pollute the traceToken below. Check my comment below.
There was a problem hiding this comment.
Add a new branch here: else if (trimEmptyToNull(servletRequest.getHeader(PRESTO_TRACE_TOKEN)) != null) or something like that. And inside the body, we can either create a SimpleTracerProvider and get the token or directly assign traceToken from PRESTO_TRACE_TOKEN
There was a problem hiding this comment.
updated trace token to replicate similar logic as before
There was a problem hiding this comment.
nit: it's not critical but good to follow:
we don't usually name a function or var with word "Map"; instead, we use getRequestHeaders. Same for the variable headerMap --> headers. And everything else in the PR.
There was a problem hiding this comment.
this is not a generic error; check my other comment
There was a problem hiding this comment.
two options:
- you can create your own error code class within the module with a brand new base code; check any other implementation of
ErrorCodeSupplier; or - you can just throw runtime error or put generic code to be a catch-all to save the effort, which is not recommended but fine
|
@highker Addressed nits, and made one further change for open telemetry baggage propagation. Put it in new commit so it's easier to see and will squash if it looks good. |
|
Thanks. Please squash all commits into one. |
11edf44 to
19a4184
Compare
There was a problem hiding this comment.
nit: ImmutableMap<String, String> -> Map<String, String>
There was a problem hiding this comment.
nit: Optional.of(tunnelTraceId)
it's not null already
There was a problem hiding this comment.
nit: ImmutableMap<String, String> -> Map<String, String>
There was a problem hiding this comment.
comment not addressed? https://github.com/prestodb/presto/pull/18534/files#r1035527320
There was a problem hiding this comment.
I'm not expert in open telemetry but are we sure the logic is correct by modifying static variables?
There was a problem hiding this comment.
I believe it should be fine. If we have a different context propagator, we need to rebuild the open telemetry instance for all tracers that may exist.
d227668 to
6ad17a0
Compare
There was a problem hiding this comment.
Can we delete this class from this file?
support simple tracer in new open telemetry implementation bump okhttp3 version to 4.5.0 use system val if client val not set add support for context extraction from b3 propagation and overall interface revert back to okhttp3 version 3.9.0 for this PR implement W3C baggage header extraction tracer handle implementation, remove context propagator from system property, general refactor address nits and open telemetry baggage updates
6ad17a0 to
54c6530
Compare
|
@highker Thanks for the helpful reviews and merge! |

Test plan -